package com.quartet.utils;

import cn.hutool.core.util.RandomUtil;
import com.google.common.base.CaseFormat;

/**
 * @author huipanxing
 */
public final class RandomUtils {

    public static final String CUSTOM_CODE_PREFIX = "CU";
    public static final String US_CODE_PREFIX = "US";
    public static final String ORDER_CODE_PREFIX = "M";
    public static final String AUTHORIZATION_CODE = "SQM";
    public static final String VEHICLE_CODE = "CL";
    public static final String EQUIPMENT_CODE = "E";
    public static final String ORDER_KEY = "OK";

    /**
     * 生成几位随机数
     * @param n
     * @return
     */
    public static String getRandom(int n) {
        return RandomUtil.randomNumbers(n);
    }


    /**
     * 生成客户编码
     * @return
     */
    public static String getCustomerCode() {
        return CUSTOM_CODE_PREFIX + getRandom(14);
    }

    /**
     * 生成用户id
     * @return
     */
    public static Long getUserId() {
        return RandomUtil.randomLong(16);
    }

    /**
     * 生成订单编码
     * @return
     */
    public static String getOrderCode() {
        return ORDER_CODE_PREFIX + getRandom(15);
    }

    /**
     * 生成授权码 18位
     * @return
     */
    public static String getAuthorizationCode() {
        return AUTHORIZATION_CODE + getRandom(15);
    }


    /**
     * 功能描述: 转换字段格式
     * @author huipanxing huipanxing@chinasofti.com
     * @date 2021/5/22 17:28
     * @param field
     * @return java.lang.String
     */
    public static String getField(String field) {
        return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field);
    }

    /**
     * 生成车辆编码
     * @return
     */
    public static String getVehicleCode() {
        return VEHICLE_CODE + getRandom(14);
    }

    /**
     * 生成设备编码
     * @return
     */
    public static String getEquipmentCode() {
        return EQUIPMENT_CODE + getRandom(15);
    }

    /**
     * 生成订单key
     * @return
     */
    public static String getOrderKey() {
        return ORDER_KEY + getRandom(30);
    }

    public static void main(String[] args) {
        System.out.println(getOrderKey());
    }
}
